package com.elminster.graphic;

import java.util.ArrayList;
import java.util.List;

import com.elminster.graphic.entity.GraphicEntity;

public abstract class GraphicBase implements IGraphic {
    
    protected List<GraphicEntity> entity;
    protected boolean merge = true;
    protected int width;
    protected int height;

    public List<GraphicEntity> getGraphicEntity() {
        return entity;
    }

    public boolean isMerge() {
        return merge;
    }

    public void setGraphicEntity(List<GraphicEntity> entity) {
        this.entity = entity;
    }

    public void setMerge(boolean isMerge) {
        this.merge = isMerge;        
    }

    public int getWidth() {
        return width;
    }
    
    public void setWidth(int width) {
        this.width = width;
    }

    public int getHeight() {
        return height;
    }

    public void setHeight(int height) {
        this.height = height;
    }

    protected List<GraphicEntity> meger() {
        List<GraphicEntity> megeredEntity = new ArrayList<GraphicEntity>();
        for (GraphicEntity e : entity) {
            int idx = megeredEntity.indexOf(e);
            if (0 <= idx) {
                megeredEntity.get(idx).add(e);
            } else {
                megeredEntity.add(e);
            }
        }
        return megeredEntity;
    }
}
